//
//  HomeHeadView.m
//  digitalCurrency
//
//  Created by 默认账户 on 2019/4/3.
//  Copyright © 2019 XinHuoKeJi. All rights reserved.
//

#import "HomeHeadView.h"

@interface HomeHeadView ()
  
@property (nonatomic, strong) UIView *leftBgview;

@property (nonatomic, strong) UIImageView *firstRightImgView;
@property (nonatomic, strong) UIImageView *firstBottomImgView;

@property (nonatomic, strong) UIView *rightBgview;

@property (nonatomic, strong) UIImageView *secRightImgView;
@property (nonatomic, strong) UIImageView *secBottomImgView;

@end

@implementation HomeHeadView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = [UIColor blackColor];
        [self makeview];
    }
    return self;
}

- (void)makeview {
    
    CGFloat bgwidth = (SCREEN_WIDTH-36)/2.0;
    
    [self addSubview:self.leftBgview];
    [self.leftBgview mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(12);
        make.width.mas_equalTo(bgwidth);
        make.top.mas_equalTo(20);
        make.bottom.mas_equalTo(-5);
        
    }];
    
    [self.leftBgview addSubview:self.amountCoin];
    [self.amountCoin mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(12);
        make.top.mas_equalTo(12);
        make.height.mas_equalTo(18);
    }];
    
    [self.leftBgview addSubview:self.amountTitle];
    [self.amountTitle mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(12);
        make.top.mas_equalTo(40);
        make.height.mas_equalTo(18);
    }];
    
    [self.leftBgview addSubview:self.firstRightImgView];
    [self.firstRightImgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(-12);
        make.top.mas_equalTo(12);
        make.width.height.mas_equalTo(32);
    }];
    
    [self.leftBgview addSubview:self.firstBottomImgView];
    [self.firstBottomImgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(-12);
        make.left.mas_equalTo(12);
        make.bottom.mas_equalTo(-12);
        make.height.mas_equalTo(20);
    }];
    
    [self addSubview:self.rightBgview];
    [self.rightBgview mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(-12);
        make.width.mas_equalTo(bgwidth);
        make.top.mas_equalTo(20);
        make.bottom.mas_equalTo(-5);
        
    }];
    
    [self.rightBgview addSubview:self.canUsedCoin];
    [self.canUsedCoin mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(12);
        make.top.mas_equalTo(12);
        make.height.mas_equalTo(18);
    }];
    
    [self.rightBgview addSubview:self.canUsedTitle];
    [self.canUsedTitle mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(12);
        make.top.mas_equalTo(40);
        make.height.mas_equalTo(18);
    }];
    
    [self.rightBgview addSubview:self.secRightImgView];
    [self.secRightImgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(-12);
        make.top.mas_equalTo(12);
        make.width.height.mas_equalTo(32);
    }];
    
    [self.rightBgview addSubview:self.secBottomImgView];
    [self.secBottomImgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(-12);
        make.left.mas_equalTo(12);
        make.bottom.mas_equalTo(-12);
        make.height.mas_equalTo(20);
    }];
    
    
}

- (UIView *)leftBgview {
    if (!_leftBgview) {
        _leftBgview = [[UIView alloc] init];
        _leftBgview.backgroundColor = [UIColor colorWithHEX:@"282f3a"];
        _leftBgview.layer.cornerRadius = 3;
    }
    
    return _leftBgview;
}
    
- (UIView *)rightBgview {
    if (!_rightBgview) {
        _rightBgview = [[UIView alloc] init];
        _rightBgview.backgroundColor = [UIColor colorWithHEX:@"282f3a"];
        _rightBgview.layer.cornerRadius = 3;
    }
    
    return _rightBgview;
}
    
- (UIImageView *)firstRightImgView {
    if (!_firstRightImgView) {
        _firstRightImgView = [[UIImageView alloc] init];
        _firstRightImgView.layer.cornerRadius  = 16;
        _firstRightImgView.layer.masksToBounds = YES;
        _firstRightImgView.image = [UIImage imageNamed:@"qb_head_left"];
    }
    
    return _firstRightImgView;
}

- (UIImageView *)secRightImgView {
    if (!_secRightImgView) {
        _secRightImgView = [[UIImageView alloc] init];
        _secRightImgView.layer.cornerRadius  = 16;
        _secRightImgView.layer.masksToBounds = YES;
        _secRightImgView.image = [UIImage imageNamed:@"qb_head_right"];
    }
    
    return _secRightImgView;
}
    
- (UIImageView *)firstBottomImgView {
    if (!_firstBottomImgView) {
        _firstBottomImgView = [[UIImageView alloc] init];
        _firstBottomImgView.image = [UIImage imageNamed:@"qb_line_left"];
    }
    
    return _firstBottomImgView;
}

- (UIImageView *)secBottomImgView {
    if (!_secBottomImgView) {
        _secBottomImgView = [[UIImageView alloc] init];
        _secBottomImgView.image = [UIImage imageNamed:@"qb_line_right"];
    }
    
    return _secBottomImgView;
}
    
- (UILabel *)amountCoin {
    if (!_amountCoin) {
        _amountCoin = [[UILabel alloc] init];
        _amountCoin.textColor = [UIColor whiteColor];
        _amountCoin.font = [UIFont systemFontOfSize:18];
        
        NSMutableAttributedString *string = [[NSMutableAttributedString alloc] initWithString:@"$0.00" attributes:@{NSFontAttributeName: [UIFont fontWithName:@"PingFangSC-Medium" size: 18],NSForegroundColorAttributeName: [UIColor colorWithRed:246/255.0 green:246/255.0 blue:246/255.0 alpha:1.0]}];
        _amountCoin.attributedText = string;
    }
    
    return _amountCoin;
}
    
- (UILabel *)amountTitle {
    if (!_amountTitle) {
        _amountTitle = [[UILabel alloc] init];
        _amountTitle.text = LocalizationKey(@"Total assets");
        _amountTitle.textColor = [UIColor colorWithRed:246/255.0 green:246/255.0 blue:246/255.0 alpha:1.0];
        _amountTitle.font = [UIFont systemFontOfSize:12];
    }
    
    return _amountTitle;
}
  
    
- (UILabel *)canUsedCoin {
    if (!_canUsedCoin) {
        _canUsedCoin = [[UILabel alloc] init];
        _canUsedCoin.textColor = [UIColor whiteColor];
        _canUsedCoin.font = [UIFont systemFontOfSize:18];
        
        NSMutableAttributedString *string = [[NSMutableAttributedString alloc] initWithString:@"$0.00" attributes:@{NSFontAttributeName: [UIFont fontWithName:@"PingFangSC-Medium" size: 18],NSForegroundColorAttributeName: [UIColor colorWithRed:246/255.0 green:246/255.0 blue:246/255.0 alpha:1.0]}];
        _canUsedCoin.attributedText = string;
    }
    
    return _canUsedCoin;
}
    
- (UILabel *)canUsedTitle {
    if (!_canUsedTitle) {
        _canUsedTitle = [[UILabel alloc] init];
        _canUsedTitle.textColor = [UIColor colorWithRed:246/255.0 green:246/255.0 blue:246/255.0 alpha:1.0];
        _canUsedTitle.font = [UIFont fontWithName:@"PingFangSC-Regular" size: 12];
        _canUsedTitle.text = LocalizationKey(@"Available assets");
    }
    
    return _canUsedTitle;
}
    
@end
